//
//  SegmentController.m
//  MultiSegmentControl
//
//  Created by ET|冰琳 on 16/7/4.
//  Copyright © 2016年 Ice Butterfly. All rights reserved.
//

#import "SegmentController.h"
#import "BIMultiSegmentControl.h"
#import "MultiCustomSegmentView.h"

@interface SegmentController ()<MultiSegmentSplitViewDataSource>

@end

@implementation SegmentController

- (void)viewDidLoad{
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    BIMultiSegmentControl * control = [[BIMultiSegmentControl alloc] initWithFrame:CGRectMake(0, 100, 320, 44) titles:@[@"新闻",@"体育",@"音乐",@"视频",@"科技",@"搞笑",@"游戏",@"政治",@"热点"]];
    control.backgroundColor = [UIColor orangeColor];
    [self.view addSubview:control];
    
    
    MultiCustomSegmentView *segmentView = [MultiCustomSegmentView segmentViewWithTitles:@[@"状态",@"类型"] andFrame:CGRectMake(0, 200,320, 44)];
    
    segmentView.dataSource = self;
    segmentView.dropContainer = self.view;
    [self.view addSubview:segmentView];

}

#pragma mark- MultiSegmentSplitViewDataSource
- (NSInteger)numberOfRowsInComponent:(NSInteger)component AtSegmentIndex:(NSInteger)segmentIndex{
    if(segmentIndex == 0){
        return 5;
    }else{
        return 2;
    }
}
- (void)didSelectAtSegmentIndex:(NSInteger)segmentIndex component:(NSInteger)component row:(NSInteger)row{
    
}

- (NSString *)titleForCellAtSegmentIndex:(NSInteger)segmentIndex component:(NSInteger)component row:(NSInteger)row{
    if (segmentIndex == 0) {
        NSArray *ary = @[@"等待付款",@"交易成功",@"未交易",@"发货中",@"服务中"];
        return ary[row];
    }else{
        NSArray *ary = @[@"状态1",@"状态2"];
        return ary[row];
    }
}

@end
